//
//  CertificateCell.m
//  VideoExam
//
//  Created by apple on 2020/4/17.
//

#import "CertificateCell.h"
@interface CertificateCell ()
@property(nonatomic,strong)UIView * baseView;
@property(nonatomic,strong)UILabel * showTitleLabel;
@property(nonatomic,strong)QMUILabel * typeLabel;
@property(nonatomic,strong)UILabel * timeLabel;
@property(nonatomic,strong)UIImageView * certificateImageView;
@property(nonatomic,assign)CGFloat cellHeight;
@property(nonatomic,strong)UIImageView * angle_imageView;

@end
@implementation CertificateCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self uiSet];
    }
    return self;
}
- (void)uiSet {
      self.baseView = [[UIView alloc] initWithFrame:CGRectMake(20, 10, SCREEN_WIDTH -40, (SCREEN_WIDTH -40)*0.59)];
      self.baseView.backgroundColor=[UIColor whiteColor];
      self.baseView.layer.cornerRadius=12;
      self.baseView.layer.masksToBounds=YES;
      [self.contentView addSubview:self.baseView];
      
      
      self.certificateImageView =[UIFactory create_ImageView_ImageName:@""];
    self.certificateImageView.backgroundColor = color(@"#F0F0F0");
      [self.baseView addSubview:self.certificateImageView];
      [self.certificateImageView mas_makeConstraints:^(MASConstraintMaker *make) {
          make.edges.mas_equalTo(self.baseView);
      }];
    
      self.angle_imageView =[UIFactory create_ImageView_ImageName:@"证书角标"];
     [self.baseView addSubview:self.angle_imageView];
     [self.angle_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.right.mas_equalTo(self.baseView);
         make.top.mas_equalTo(0);
         make.size.mas_equalTo(CGSizeMake(78, 78));
     }];
    
    self.typeLabel = [UIFactory create_LabelContent:@"钢琴" textColor:[UIColor whiteColor] fontSize:12];
    self.typeLabel.textAlignment = NSTextAlignmentCenter;
    self.typeLabel.frame = CGRectMake(10, -10, 78, 78);
    [self.angle_imageView addSubview:self.typeLabel];
    self.typeLabel.transform = CGAffineTransformMakeRotation(M_PI_4-0.03);

    UIView * bottomView = [[UIView alloc] initWithFrame:CGRectZero];
    bottomView.backgroundColor = RGBA(0, 0, 0, 0.4);
    [self.baseView addSubview:bottomView];
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.baseView);
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(30);
    }];
    
    
     self.showTitleLabel = [UIFactory create_LabelContent:@"中国音乐考级协会" textColor:[UIColor whiteColor] fontSize:12];
      [bottomView addSubview:self.showTitleLabel];
      [self.showTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
          make.top.mas_equalTo(0);
          make.left.mas_equalTo(12);
          make.height.mas_equalTo(bottomView);
      }];
    
      
    self.timeLabel = [UIFactory create_LabelContent:@"2020-03-20 12:20" textColor:[UIColor whiteColor] fontSize:12];
    self.timeLabel.textAlignment=NSTextAlignmentRight;
    [bottomView addSubview:self.timeLabel];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
         make.top.mas_equalTo(0);
         make.right.mas_equalTo(bottomView.mas_right).offset(-12);
         make.height.mas_equalTo(bottomView);
    }];
      
    self.cellHeight=self.baseView.bottom+10;
   
}
- (void)setModel:(CertificateModel *)model {
    _model=model;
    _model.cellHeight=self.cellHeight;
    [self.certificateImageView sd_setImageWithURL:[NSURL URLWithString:_model.url] placeholderImage:UIImageMake(@"大占位图")];
    self.showTitleLabel.text=_model.committeeName;
    self.timeLabel.text=_model.inspectionEndDate;

}
@end
